# %%
import tensorflow as tf
print(tf.__version__)
# %%
from tensorflow.keras.layers import Input
my_input = Input(shape = (10, 10, 1))
# %%
from tensorflow.keras.layers import Convolution2D
my_output = Convolution2D(1, 3)(my_input)

# %%
from tensorflow.keras.layers import Activation
my_output = Activation('sigmoid')(my_output)
# %%
from tensorflow.keras import Model
model = Model(my_input, my_output)
# %%
model.summary()
# 这是第一个例子，非常清晰。
# %%
# ########### example 2 ###############
my_input = Input(shape=(10, 10, 1))
my_output = Convolution2D(5, 3)(my_input)
my_output = Activation('sigmoid')(my_output)
my_output = Convolution2D(2, 3)(my_output)
my_output = Activation('sigmoid')(my_output)
model = Model(my_input, my_output)
# 这个例子是关键。
# 整个作为一个input。
model.summary()
# %%
# ########### example 3 ###############
my_input = Input(shape=(10, 10, 3))
my_output = Convolution2D(8, 3)(my_input)
my_output = Activation('sigmoid')(my_output)
my_output = Convolution2D(1, 3)(my_output)
my_output = Activation('sigmoid')(my_output)
model = Model(my_input, my_output)

model.summary()
# %%
# ########### example 3 ###############
from tensorflow.keras.layers import LSTM
# define model
timestep = 40       # dimensionality of the input sequence
features = 3 # dimensionality of the representation in the sequence
LSTMoutputDimension = 2 # dimensionality of the LSTM outputs (Hidden & Cell states)

input = Input(shape=(timestep, features))
output = LSTM(LSTMoutputDimension)(input)
model_LSTM = Model(inputs=input, outputs=output)

model_LSTM.summary()
# %%
from tensorflow.keras.layers import Dense
input = Input((None, 3))
dense = Dense(5)(input)
output = Dense(2)(dense)
model_dense = Model(input, output)
model_dense.summary()

# %%
